using MemoryPack;

namespace Voxels {
	[MemoryPackable]
	public partial class VisibilityFlagsHolder {
		[MemoryPackInclude]
		public virtual VisibilityFlags[] Data {
			get {
				return _data;
			}
			set {
				_data = value;
			}
		}
		VisibilityFlags[] _data = null;

		[MemoryPackInclude]
		public int X = 0;
		[MemoryPackInclude]
		public int Y = 0;
		[MemoryPackInclude]
		public int Z = 0;

		public VisibilityFlagsHolder() {
		}

		[MemoryPackConstructor]
		public VisibilityFlagsHolder(int x, int y, int z, VisibilityFlags[] data) {
			X = x;
			Y = y;
			Z = z;
			Data = data;
		}

		public VisibilityFlagsHolder(int sizeX, int sizeY, int sizeZ) {
			X = sizeX;
			Y = sizeY;
			Z = sizeZ;
			Data = new VisibilityFlags[sizeX * sizeY * sizeZ];
		}

		[MemoryPackIgnore]
		public VisibilityFlags this[int x, int y, int z] {
			get {
				return _data[y * Z * X + z * X + x];
			}
			set {
				_data[y * Z * X + z * X + x] = value;
			}
		}

		[MemoryPackIgnore]
		public VisibilityFlags this[int pointer] {
			get {
				return _data[pointer];
			}
			set {
				_data[pointer] = value;
			}
		}
	}
}
